package com.czp.ssm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.czp.ssm.bean.Company;
import com.czp.ssm.bean.Hotel;
import com.czp.ssm.bean.HotelOrder;
import com.czp.ssm.bean.Msg;
import com.czp.ssm.bean.PlaneOrder;
import com.czp.ssm.bean.User;
import com.czp.ssm.service.CompanyService;
import com.czp.ssm.service.HotelService;
import com.czp.ssm.service.UserService;

@Controller
@RequestMapping("/companyController")
public class CompanyController {

	
	@Autowired
	private CompanyService companyService;

	@Autowired
	private UserService userService;
	/**
	 * 企业管理
	 * @return
	 */
	@RequestMapping("/companyManage")
	public ModelAndView companyManage() {
		List<Company> companyList = companyService.findAllCompanyList();
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("companyList", companyList);
		modelAndView.setViewName("background/company/companyList");
		return modelAndView;
	}
	
	/**
	 * 企业管理
	 * @return
	 */
	@RequestMapping(value="/companyDetail/{id}")
	public ModelAndView companyDetail(@PathVariable String id) {
		System.out.println("---------"+id);
		Company company = companyService.findCompanyById(Long.parseLong(id));
		System.out.println(company);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("company", company);
		modelAndView.setViewName("background/company/companyDetail");
		return modelAndView;
	}
	
	/**
	 * 员工管理，只有企业登陆才会显示，根据当前企业显示员工信息
	 * @return
	 */
	@RequestMapping(value="/employeeManage")
	public ModelAndView employeeManage() {
		String companyId = "0001";
		List<User> userList = userService.findUserByCompanyId(companyId);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("userList", userList);
		modelAndView.setViewName("background/company/employeeList");
		return modelAndView;
	}
	
	
	
}
